package com.codemobiles.droidslator;

import android.content.Context;
import android.content.SharedPreferences;

public class AppPreferences {
  
  private static AppPreferences instance = null;
  private SharedPreferences settings;
  
  public static final String PLUGIN_LEXITRON = "PLUGIN_LEXITRON";
  public static final String PLUGIN_OCR_EN = "PLUGIN_OCR_EN";
  public static final String FROM_LANG_CODE  = "FROM_LANG_CODE";
  public static final String TO_LANG_CODE  = "TO_LANG_CODE";
  
  public static AppPreferences getInstance(Context context){
  
    if (instance == null){
      instance = new AppPreferences();
      final String PREF_STR = "DROIDSLATOR_PREF";
      instance.settings = context.getSharedPreferences(PREF_STR, 0);
    }
    return instance;
  }
  
  public final String getStringValueOf(final String key){  
    return instance.settings.getString(key, null);
  }
  
  public final String getStringValueOf(final String key, final String defaultVal){  
    return instance.settings.getString(key, defaultVal);
  }
  
  
  
  public  final boolean getBooleanValueOf(final String key){  
    return instance.settings.getBoolean(key, false);
  }
  
  public void setValueOf(final String key, final boolean value){
    SharedPreferences.Editor editor = instance.settings.edit();
    editor.putBoolean(key, value);
    editor.commit();  
  }
  
  public void setValueOf(final String key, final String value){
    
    SharedPreferences.Editor editor = instance.settings.edit();
    editor.putString(key, value);
    editor.commit();  
  }
}
